//
// Created by Administrator on 2024/3/17.
//
// O(nlog(n))分治策略+归并排序
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int SENTINEL = numeric_limits<int>::max();

void merge(vector<int> &A, int left, int mid, int right, ll &cnt) {
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> L(n1 + 1, 0);
    vector<int> R(n2 + 1, 0);
    for (int i = 0; i < n1; i++)
        L[i] = A[left + i];
    for (int i = 0; i < n2; i++)
        R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k <= right - 1; k++) {

        if (L[i] <= R[j])
            A[k] = L[i++];
        else {
            A[k] = R[j++];
            cnt += n1 - i;
        }
    }
}

void merge_sort(vector<int> &A, int left, int right, ll &comp) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(A, left, mid, comp);
        merge_sort(A, mid, right, comp);
        merge(A, left, mid, right, comp);
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &e : v)
        cin >> e;
    long long cnt = 0;
    merge_sort(v, 0, v.size(), cnt);
    cout << cnt << endl;

    return 0;
}